package com.custom.topic;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        ApplicationContext context = new AnnotationConfigApplicationContext(TopicMqConfiguration.class);

        // 单元测试会额外再创建一个spring容器对象,也就是说都会扫描到TopicConsumer对象,
        // 也就是有2个消费对象TopicConsumer,这样会导致接收消息不准确,所以采用下面的方式测试
        TopicProducer producer = context.getBean(TopicProducer.class);
        producer.send();

        System.in.read();
    }

}
